import 'package:boss/models/reback_order_list_data.dart';
import 'package:boss/models/takeout_order_list_data.dart';
import 'package:boss/ui/page/takeoutManagement/constant/takeout_status.dart';
import 'package:boss/ui/widget/shadow_radius_card.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

import 'abnormal_button_group.dart';
import 'compluted_button_group.dart';
import 'new_order_button_group.dart';
import 'reback_button_group.dart';
import 'self_pickup_button_group.dart';
import 'take_packup_button_group.dart';

class TakeoutButtonGroup extends StatelessWidget {
  final TakeoutOrderItem data;
  final RebackOrderItem rebackOrder;
  final int type;

  const TakeoutButtonGroup({
    Key key,
    this.data,
    this.rebackOrder,
    this.type = 0,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Widget child;

    //异常单
    if (data?.systemOrderStatus == TakeoutStatus.ABNORMA_ORDER)
      child = AbnormalButtonGroup(
        data: data,
      );

    //待配送
    if (data?.systemOrderStatus == TakeoutStatus.TAKE_PICKUP) {
      child = TakePickupButtonGroup(
        data: data,
      );
    }

    //新订单
    if (data?.systemOrderStatus == TakeoutStatus.NEW_ORDER)
      child = NewOrderButtonGroup(
        data: data,
      );

    //已完成
    if (data?.systemOrderStatus == TakeoutStatus.COMPLETED)
      child = ComplutedButtonGroup(data: data);

    //待提货
    if (data?.systemOrderStatus == TakeoutStatus.WAIT_PICKUP)
      child = SelfPickupButtonGroup(
        data: data,
      );

    //售后单
    if (rebackOrder != null)
      child = RebackButtonGroup(data: rebackOrder,);

    if (child != null && type == 1)
      child = Container(
        height: 128.w + MediaQuery.of(context).padding.bottom,
        padding: EdgeInsets.only(
          bottom: MediaQuery.of(context).padding.bottom,
          left: 30.w,
          right: 30.w,
        ),
        alignment: Alignment.center,
        decoration: BoxDecoration(
          color: Colors.white,
          boxShadow: [DEFAULT_SHADOW],
        ),
        child: child,
      );
    return child ?? SizedBox();
  }
}
